home *** CD-ROM | disk | FTP | other *** search
- ;;;; ----------------------------------------------------------------------
- ;;;; PURPOSE: drag&drop send routine for "XXX" data
- ;;;;
- ;;;; Widgets that are to participate in drag&drop operations for
- ;;;; "XXX" data should be registered as follows:
- ;;;;
- ;;;; (blt_drag&drop .win 'source 'handler 'XXX 'dd-send-color)
- ;;;; (blt_drag&drop .win 'target 'handler 'XXX 'my-color-handler)
- ;;;;
- ;;;; (define (my-color-handler)
- ;;;; (let ((data (hash-table-get DragDrop 'XXX ;;;;f)))
- ;;;; (if data
- ;;;; .
- ;;;; . do something with $data
- ;;;; .
- ;;;; )))
- ;;;; ORIGINAL AUTHOR: Michael J. McLennan Phone: (215)770-2842
- ;;;; AT&T Bell Laboratories E-mail: aluxpo!mmc@att.com
- ;;;;
- ;;;; ----------------------------------------------------------------------
- ;;;; Copyright (c) 1993 AT&T All Rights Reserved
- ;;;; ======================================================================
-
- ;;;;
- ;;;; rewritten for STk by Erick Gallesio [eg@unice.fr]
- ;;;; Creation date: 7-Jul-1994 10:13
- ;;;; Last file update: 28-Dec-1995 00:33
-
- (require "hash")
- (require "stklos")
-
- (define DragDrop (make-hash-table))
-
- (define (make-drag&drop-label win . args)
- (let ((token-name (& win ".label")))
- ; Use catch since label can fail (id the window has previously be created)
- (catch (pack (label token-name)))
- ;; Now configure it to the given arguments
- (apply (string->widget token-name) 'configure args)))
-
- (define (drag&drop . l)
- (apply blt_drag&drop (map (lambda(x) (if (instance? x) (slot-ref x 'Id) x)) l)))
-
- (define (drag&drop-configure win . args)
- (let ((pc (get-keyword :package-command args #f))
- (sh (get-keyword :source-handler args #f))
- (th (get-keyword :target-handler args #f)))
- (when pc (drag&drop 'source win 'config :package pc))
- (when sh (apply drag&drop 'source win 'handler sh))
- (when th (apply drag&drop 'target win 'handler th))))
-
- ;;;; ----------------------------------------------------------------------
- ;;;; (dd-send-color <interp> <ddwin> <data>)
- ;;;;
- ;;;; INPUTS
- ;;;; <interp> = interpreter for target application
- ;;;; <ddwin> = pathname for target drag&drop window
- ;;;; <data> = data returned from -tokencmd
- ;;;;
- ;;;; RETURNS
- ;;;; ""
- ;;;;
- ;;;; SIDE-EFFECTS
- ;;;; Sends data to remote application DragDrop(color), and then
- ;;;; invokes the "color" handler for the drag&drop target.
- ;;;; ----------------------------------------------------------------------
- (define (dd-send-color interp ddwin data)
- (send interp `(begin
- ;; Verify it is a color
- (winfo 'rgb *root* ',data)
- (hash-table-put! DragDrop 'color ',data)))
- (send interp `(blt_drag&drop 'target ,ddwin 'handle 'color))
- "")
-
- ;;;; ----------------------------------------------------------------------
- ;;;; dd-send-number <interp> <ddwin> <data>
- ;;;;
- ;;;; INPUTS
- ;;;; <interp> = interpreter for target application
- ;;;; <ddwin> = pathname for target drag&drop window
- ;;;; <data> = data returned from -tokencmd
- ;;;;
- ;;;; RETURNS
- ;;;; ""
- ;;;;
- ;;;; SIDE-EFFECTS
- ;;;; Sends data to remote application DragDrop(number), and then
- ;;;; invokes the "number" handler for the drag&drop target.
- ;;;; ----------------------------------------------------------------------
- (define (dd-send-number interp ddwin data)
- (send interp `(let ((x (if (string? ,data) (string->number ,data) ,data)))
- (unless (number? x)
- (error "dd-send-number: nbad number: ~S." x))
- (hash-table-put! DragDrop 'number x)))
- (send interp `(blt_drag&drop 'target ,ddwin 'handle 'number))
- "")
-
- ;;;; ----------------------------------------------------------------------
- ;;;; (dd-send-text <interp> <ddwin> <data>)
- ;;;;
- ;;;; INPUTS
- ;;;; <interp> = interpreter for target application
- ;;;; <ddwin> = pathname for target drag&drop window
- ;;;; <data> = data returned from -tokencmd
- ;;;;
- ;;;; RETURNS
- ;;;; ""
- ;;;;
- ;;;; SIDE-EFFECTS
- ;;;; Sends data to remote application DragDrop(text), and then
- ;;;; invokes the "text" handler for the drag&drop target.
- ;;;; ----------------------------------------------------------------------
- (define (dd-send-text interp ddwin data)
- (send interp `(hash-table-put! DragDrop 'text ,data))
- (send interp `(blt_drag&drop 'target ,ddwin 'handle 'text))
- "")
-
- (provide "dd-protocol.stklos")
-